/**
 * @author LKQ
 * @date 2022/2/2 15:47
 * @description
 */
public class FormalSolution3 {
    public static void main(String[] args) {

    }
    public int hammingDistance(int x, int y) {
        int s = x ^ y, ret = 0;
        while (s != 0) {
            // 每次减去最右侧的1，减少循环次数
            s &= s - 1;
            ret++;
        }
        return ret;

    }
}
